package com.kfm.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/files")
public class ListFileServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html; charset=utf-8");

        PrintWriter writer = response.getWriter();

        StringBuffer sb = new StringBuffer();

        sb.append("""
                <table border="1">
                    <tr>
                        <th>编号</th>
                        <th>姓名</th>
                    </tr>
                    <tr>
                        <td>1</td>
                        <td>张三</td>
                    </tr>
                    <tr>
                        <td>2</td>
                        <td>李四</td>
                    </tr>
                </table>
                """);

        writer.write(sb.toString());
    }
}
